// pages/user_end/leave_comment/leave_comment.js
const app = getApp();
const request = require('../../../utils/request.js');
const url = require('../../../utils/url.js');
const cookie = require('../../../utils/cookie.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    result: ['不想要了', '发货时间太长'],
    index: '',
    show: true,
    active: 1,
    rate:5,
    content:"",
    id:0,
    order:[],
    imgs:[],
    picList:[],
    token:'',
    star:5,
	captcha:"",
	countdown: 60,
	isDisabled: false,
	btnText:"发送验证码"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this;
    that.setData({
       id:options.id
    })
    cookie.getCookie('userInfo', function (res) {
      if (res) {
        var etime = Date.parse(new Date()) / 1000;
        
        if (etime < res.expiretime) {
          that.setData({
            login: 1,
            token:res.token
          })
          that.getOrder();
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  getOrder: function() {
    var that = this;
    let param = {
        id:that.data.id,
        token:that.data.token
    }
    wx.showNavigationBarLoading();  //在当前页面显示导航条加载动画
    request.request(url.detailexpert, param, url.REQUEST_METHOD_GET).then((res) => {
          wx.hideNavigationBarLoading(); //在当前页面隐藏导航条加载动画
          that.setData({
              order:res.data.data
          })
          if(res.data.data.bargain==1){
            //议价
            that.setData({
              index:2,
              cost:''
            })
          }else{
            that.setData({
              index:1
            })
          }
    })

  },
})